
import Vue from 'vue'
import App from './entry/admin'
import router from './router/admin.router'
import iView from 'iview'

// import 'iview/dist/styles/iview.css'
// import '../my-theme/dist/iview.css'
import '../my-theme/index.less'
// require('!style-loader!css-loader!less-loader!./styles/index.less'); 
import projectTypeForm from './views/admin/project/projectTypeForm/projectTyoeForm'
import industryTypeForm from './views/admin/project/industryTypeForm/industryTypeForm'
import contact_yForm from './views/admin/role/contact_y/contact_yForm'
import contact_nForm from './views/admin/role/contact_n/contact_nForm'
import axios from 'axios'
import Qs from 'qs'
import VueAxios from 'vue-axios'
import common  from "./views/common/common"
import apis from "./views/admin/apis/apis"
Vue.prototype.common=common
Vue.prototype.apis=apis
Vue.use(iView)
Vue.use(projectTypeForm)
Vue.use(industryTypeForm)
Vue.use(contact_yForm)
Vue.use(contact_nForm)
//设置cookie
Vue.prototype.setCookie=function(cname, cvalue, exminutes,path) {
        var millisecond = new Date().getTime();
        var expiresTime = new Date(millisecond + 60 * 1000 * exminutes);
        document.cookie="admin="+this.formInline.user+";path="+path+";expires="+expiresTime
   }
//获取cookie
Vue.prototype.getCookie= function(cname) {
    　　var name = cname + "=";
    　　var ca = document.cookie.split(";");
    　　for (var i = 0; i < ca.length; i++) {
    　　var c = ca[i];
    　　while (c.charAt(0) == " ") c = c.substring(1);
    　　if (c.indexOf(name) != -1) return c.substring(name.length, c.length);
    }
    return "";
   }

var axios_instance = axios.create({
    baseURL:'http://47.101.180.43:8080', //自行修改url,
    transformRequest: [function (data) {
    data = Qs.stringify(data);
    return data;
    }],
    headers:{'Content-Type':'application/x-www-form-urlencoded',
    'Access-Control-Allow-Credentials': 'true'}
    })
Vue.use(VueAxios, axios_instance)
/**axios不是vue插件，所以需要这样配置，可以通过this.$http代替axios，而不用每个.vue里面再去import axios了 */
Vue.prototype.$ajax=axios
/**运行跨域请求*/
axios.defaults.withCredentials=true

new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
